dict1 = {"a": 1, "b": 2, "c": 3}
try:
    x = dict1['y']
# except (只是)
except KeyError:
    print('键错误')
except LookupError:
    print('查询错误')
else:
    print(x)
finally:
    print('finally')

# Python 使用 raise(提升) 语句抛出一个指定的异常。
try:
    raise NameError('HiThere')
except NameError:
    print('An exception flew by!')
